# Maintainer: Thore Bödecker <foxxx0@archlinux.org>

_gemname='fakeweb'
pkgname="ruby-${_gemname}"
pkgver=1.3.0
pkgrel=2
pkgdesc="Ruby test helper for injecting fake responses to web requests"
url="https://github.com/chrisk/fakeweb"
arch=('any')
license=('MIT')
depends=('ruby')
makedepends=('ruby-rake' 'ruby-rspec' 'ruby-bundler' 'ruby-rdoc' 'ruby-test-unit')
checkdepends=('ruby-mocha')
options=('!emptydirs')
source=("${_gemname}-v${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz")
sha512sums=('2e9c4848fc3733fe54f30d80db5c2d8a4e9148640e3fcce67c087096a5739273cf5bf6b3b981dd284ab78da6af8e4ab995a4021b53964bb24f72d9a7d219c0f6')

prepare() {
  cd "${srcdir}/${_gemname}-${pkgver}"
  :
}

build() {
  cd "${srcdir}/${_gemname}-${pkgver}"
  mkdir -p pkg
  gem build -o "pkg/${_gemname}-${pkgver}.gem"
}

check() {
  cd "${srcdir}/${_gemname}-${pkgver}"
  # tests are broken and require outdated/non-existing gems, upstream seems dead in this regard
  #rake test
}

package() {
  cd "${srcdir}/${_gemname}-${pkgver}"
  local _gemdir="$(gem env gemdir)"
  gem install \
    --ignore-dependencies \
    --no-user-install \
    -i "${pkgdir}/${_gemdir}" \
    -n "${pkgdir}/usr/bin"  \
    "pkg/${_gemname}-${pkgver}.gem"

  # cd "${pkgdir}/${_gemdir}"
  # rm -r cache gems/"${_gemname}-${pkgver}"/{ext,tmp,lib/*/*.so} \
  #   extensions/*/*/"${_gemname}-${pkgver}"/{mkmf.log,gem_make.out}

  install -D -m644 "LICENSE.txt" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

# vim: ts=2 sw=2 et:
